class Linking
  include Mongoid::Document
  include Mongoid::Timestamps



  field :level_id,:type => Integer
  field :grade_id,:type => Integer
  field :course_id,:type => Integer
  field :recommend, :type => Boolean, :default => false




  validates  :level_id, :presence => true, :uniqueness => {:scope => [:grade_id, :course_id]}
  validates  :grade_id, :presence => true, :uniqueness => {:scope => [:level_id, :course_id]}
  validates  :course_id, :presence => true, :uniqueness => {:scope => [:grade_id, :level_id]}



  index({ :level_id => 1,:grade_id => 1,:course_id => 1}, { :unique => true,:background=>true })
  index({ :level_id => 1,:grade_id => 1})
  index({ :level_id => 1,:course_id => 1})
  index({ :grade_id => 1,:course_id => 1})
  index :level_id => 1
  index :grade_id => 1
  index :course_id => 1
  index :recommend => 1






  belongs_to :level
  belongs_to :grade
  belongs_to :course
end
